package com.jinyou.chengfengshop.adapter;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.squareup.picasso.Picasso;
import com.jinyou.chengfengshop.MainActivity;
import com.jinyou.chengfengshop.R;
import com.jinyou.chengfengshop.activity.OrderDetailsActivity;

import java.util.List;

/**
 * Created by Raul_lsj on 2018/3/28.
 */

public class ScrollRightAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHolder> {

    private ImageView img_order;
    public ScrollRightAdapter(int layoutResId, int sectionHeadResId, List<ScrollBean> data) {
        super(layoutResId, sectionHeadResId, data);
    }


    @Override
    protected void convertHead(BaseViewHolder helper, ScrollBean item) {
        helper.setText(R.id.right_title, item.header);

    }

    @Override
    protected void convert(BaseViewHolder helper, ScrollBean item) {
        final ScrollBean.ScrollItemBean t = item.t;
        helper.setText(R.id.right_text, t.getText());
        img_order = helper.getView(R.id.img_order);
        Picasso.with(MainActivity.context)
                .load(t.getUrl())
                .into(img_order);
        helper.setOnClickListener(R.id.img_order, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent mIntent = new Intent(MainActivity.context, OrderDetailsActivity.class);
                mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                mIntent.putExtra("ORDER",t.getOrderB());
                MainActivity.context.startActivity(mIntent);
            }
        });
        //Toast.makeText(MainActivity.context,t.getText(),Toast.LENGTH_SHORT).show();这里可以通知显示订单详情
    }
}
